//真值缩小
function printAll2(strs: string | string[] | null) {
  if (strs) {
    if (typeof strs === 'object') {
      for (const s of strs) {
        console.log(s);
      }
    } else if (typeof strs === 'string') {
      console.log(strs);
    } else {
      //...
    }
  }
}

function multiplyAll(values: number[] | undefined, factor: number) {
  if (!values) {
    return values
  } else {
    return values.map(x => {
      return x * factor
    })
  }
}

console.log(multiplyAll([2, 3], 2));
console.log(multiplyAll(undefined, 2));
